/*
 * @Description:
 * @Author: Richeneen
 * @Date: 2022-10-13 10:05:11
 * @LastEditTime: 2022-10-23 14:17:48
 * @LastEditors: Richeneen
 */
import { queryEmployee, queryEmployeeAccount, queryCustomer, queryCustomerAccount, querySystemAccount } from '@/api/accountBill'
import { param } from '@/utils'

export default {
  namespaced: true,
  state: {
    // 员工编号
    employees: [],
    // 员工账单
    employeesAccount: [],
    // 顾客编号
    customers: [],
    // 顾客账单
    customersAccount: [],
    // 系统账单
    systemAccount: []
  },
  mutations: {
    // 更改员工编号
    SET_EMPLOYEES(state, payload) {
      state.employees = payload
    },
    // 更改员工账单信息
    SET_EMPLOYEESACCOUNT(state, payload) {
      state.employeesAccount = payload
    },
    // 更改顾客编号
    SET_CUSTOMERS(state, payload) {
      state.customers = payload
    },
    // 更改顾客账单信息
    SET_CUSTOMERSACCOUNT(state, payload) {
      state.customersAccount = payload
    },
    // 更改系统账单信息
    SET_SYSTEMACCOUNT(state, payload) {
      state.systemAccount = payload
    }
  },
  actions: {
    // 获取员工编号
    async queryEmployee({ commit }, params) {
      const res = await queryEmployee(params)
      commit('SET_EMPLOYEES', res.data.list)
    },
    // 获取员工账单
    async queryEmployeeAccount({ commit }, params) {
      const res = await queryEmployeeAccount(params)
      commit('SET_EMPLOYEESACCOUNT', res.data)
    },
    // 获取顾客编号：
    async queryCustomer({ commit }, params) {
      const res = await queryCustomer(params)
      commit('SET_CUSTOMERS', res.data.list)
    },
    // 获取顾客账单
    async queryCustomerAccount({ commit }, params) {
      const res = await queryCustomerAccount(params)
      commit('SET_CUSTOMERSACCOUNT', res.data)
    },
    // 获取系统账单
    async querySystemAccount({ commit }, params) {
      const res = await querySystemAccount(params)
      commit('SET_SYSTEMACCOUNT', res.data)
    }
  }
}
